from frameworks.utils.db import *

class BaseModel(object):
    db = ''
    table = ''

    def __init__(self,dbname="deploy"):
        self.db = DB(dbname)

    def getMapData(self,rs,fields):
        newrs = []
        if rs != None and rs != False and len(rs) > 0:
            for row in rs:
                option = {}
                i = 0
                for fieldname in fields:
                    if fieldname == "ctime" or fieldname == "mtime":
                        option[fieldname] = str(row[i])
                    else:
                        option[fieldname] = row[i]
                    i += 1
                newrs.append(option)
        return newrs
